class Person {
  constructor({ name, name2 }: { name?: string; name2?: string }) {
    if (name) {
      this.name = name;
    }
    if (name2) {
      this.name2 = name2;
    }
  }
  private name!: string;
  protected name2!: string;
  sayHello() {
    return this.name;
  }
}

class Teacher extends Person {
  public sayBye() {
    console.log(this.name2);
  }
}

const person = new Person({ name: "tt" });
const person2 = new Teacher({ name2: "tt2" });

// person.name = "tt2";
console.log(person.sayHello());
